package cn.bblocks.cacheTest.suport;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @program:
 * @author: captain.ma
 * @date: 2018-12-07
 * @since: 1.0.0.0
 */
public class PriceUtils {

    public static boolean isPrice(String str) {
        if (str.startsWith("-")) {
            return false;
        }
        if (str.length() > 11) {
            return false;
        }
        Pattern pattern = Pattern.compile("[0-9]+\\.?[0-9]{0,2}");
        Matcher isNum = pattern.matcher(str);
        if (!isNum.matches()) {
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(isPrice("123.2"));
        System.out.println(isPrice("1235470896544"));
        System.out.println(isPrice("123.223"));
    }

}
